﻿<Window x:Class="PowerMon"
    x:Name="PowerMon"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:TrippLite;assembly=TrippLiteMon"
    xmlns:controls="clr-namespace:TrippLite;assembly=TLControls" 
    Height="324" Width="746"
    HorizontalAlignment="Center"
    VerticalAlignment="Center"
    ResizeMode="CanMinimize"
    Title="{Binding Title}"
    Background="{DynamicResource TrippLiteBlueGradient}" Icon="{DynamicResource TrippLiteIcon}">
    <Window.Resources>

        <Style TargetType="{x:Type Button}" x:Key="LeftButtonStyle" x:Name="LeftButtonStyle">
            <Setter Property="Background" Value="{StaticResource TrippLiteLcd}" />
            <Setter Property="Width" Value="80" />
            <Setter Property="Margin" Value="10" />
            <Setter Property="BorderBrush" Value="{DynamicResource TrippLiteLcd}" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid x:Name="ButtonContentGrid" Width="{TemplateBinding Width}"
                              Height="{TemplateBinding Height}" Opacity="0.2" ClipToBounds="True">

                            <Image Width="20" 
                                   Height="20" 
                                   HorizontalAlignment="Center" 
                                   VerticalAlignment="Center" 
                                   Source="{DynamicResource CmdLeft}"
                                   x:Name="CmdLeft"
                                   RenderOptions.BitmapScalingMode="HighQuality">

                                <Image.Effect>
                                    <DropShadowEffect BlurRadius="2" ShadowDepth="2" Color="{DynamicResource TrippLiteDimGrayColor}" />
                                </Image.Effect>

                            </Image>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="Mouse.MouseEnter">
                                <EventTrigger.Actions>
                                    <StopStoryboard BeginStoryboardName="mouseExitBeginStoryboard" />

                                    <BeginStoryboard Name="mouseEnterBeginStoryboard">
                                        <Storyboard>

                                            <DoubleAnimation 
                                                Storyboard.TargetName="ButtonContentGrid"  
                                                Storyboard.TargetProperty="Opacity" 
                                                To="1" Duration="0:0:0.15" />

                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Name="mouseExitBeginStoryboard">
                                        <Storyboard>

                                            <DoubleAnimation 
                                                Storyboard.TargetName="ButtonContentGrid"  
                                                Storyboard.TargetProperty="Opacity" 
                                                To="0.2" Duration="0:0:0.15" />

                                        </Storyboard>
                                    </BeginStoryboard>

                                    <!-- Stopping the storyboard sets all animated properties back to default. -->
                                    <StopStoryboard BeginStoryboardName="mouseEnterBeginStoryboard" />

                                </EventTrigger.Actions>
                            </EventTrigger>

                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type Button}" x:Key="RightButtonStyle" x:Name="RightButtonStyle">
            <Setter Property="Background" Value="{StaticResource TrippLiteLcd}" />
            <Setter Property="Width" Value="80" />
            <Setter Property="Margin" Value="10" />
            <Setter Property="BorderBrush" Value="{DynamicResource TrippLiteLcd}" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">
                        <Grid x:Name="ButtonContentGrid" Width="{TemplateBinding Width}"
                              Height="{TemplateBinding Height}" Opacity="0.2" ClipToBounds="True">

                            <Image Width="20" 
                                   Height="20" 
                                   HorizontalAlignment="Center" 
                                   VerticalAlignment="Center" 
                                   Source="{DynamicResource CmdRight}"
                                   x:Name="CmdRight"
                                   RenderOptions.BitmapScalingMode="HighQuality">

                                <Image.Effect>
                                    <DropShadowEffect BlurRadius="2" ShadowDepth="2" Color="{DynamicResource TrippLiteDimGrayColor}" />
                                </Image.Effect>

                            </Image>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <EventTrigger RoutedEvent="Mouse.MouseEnter">
                                <EventTrigger.Actions>
                                    <StopStoryboard BeginStoryboardName="mouseExitBeginStoryboard" />

                                    <BeginStoryboard Name="mouseEnterBeginStoryboard">
                                        <Storyboard>

                                            <DoubleAnimation 
                                                Storyboard.TargetName="ButtonContentGrid"  
                                                Storyboard.TargetProperty="Opacity" 
                                                To="1" Duration="0:0:0.15" />

                                        </Storyboard>
                                    </BeginStoryboard>
                                </EventTrigger.Actions>
                            </EventTrigger>
                            <EventTrigger RoutedEvent="Mouse.MouseLeave">
                                <EventTrigger.Actions>
                                    <BeginStoryboard Name="mouseExitBeginStoryboard">
                                        <Storyboard>

                                            <DoubleAnimation 
                                                Storyboard.TargetName="ButtonContentGrid"  
                                                Storyboard.TargetProperty="Opacity" 
                                                To="0.2" Duration="0:0:0.15" />

                                        </Storyboard>
                                    </BeginStoryboard>

                                    <!-- Stopping the storyboard sets all animated properties back to default. -->
                                    <StopStoryboard BeginStoryboardName="mouseEnterBeginStoryboard" />

                                </EventTrigger.Actions>
                            </EventTrigger>

                        </ControlTemplate.Triggers>

                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>

    <Grid VerticalAlignment="Stretch" HorizontalAlignment="Stretch" ShowGridLines="False" Width="{Binding}" Height="{Binding}">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="160" />
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0" Grid.Column="1" Grid.RowSpan="2" Background="{DynamicResource TrippLiteGray}">
            <Grid.RowDefinitions>
                <RowDefinition Height="70"/>
                <RowDefinition/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="1">
                <Grid 
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Top" 
                    Height="44" 
                    Background="{DynamicResource TrippLiteGray}"
                    Margin="12,12,12,12">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <Image Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" x:Name="LogoImage" Stretch="Uniform" Margin="4,4,4,4" Source="{StaticResource TrippLiteLogo}"/>

                </Grid>
            </Grid>
            <Grid HorizontalAlignment="Stretch" Grid.Row="1" Grid.Column="0" Grid.RowSpan="1">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="30" />
                </Grid.RowDefinitions>

                <!-- Buttons Grid -->
                <Grid Grid.Row="1" Grid.Column="1" HorizontalAlignment="Stretch" Grid.ColumnSpan="2" Margin="12,0,40,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="38" />
                        <ColumnDefinition Width="40" />
                        <ColumnDefinition Width="40" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <Button x:Name="LeftButton"
                            Grid.Column="1" 
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Top" 
                            Width="30" 
                            Height="30" 
                            Margin="1,1,1,1" 
                            Opacity="0"
                            Style="{DynamicResource LeftButtonStyle}"
                            >

                    </Button>
                    <Button x:Name="RightButton"
                            Grid.Column="2" 
                            HorizontalAlignment="Center" 
                            VerticalAlignment="Top" 
                            Width="30" 
                            Height="30" 
                            Margin="1,1,1,1" 
                            Opacity="0"
                            Style="{DynamicResource RightButtonStyle}"
                            >

                    </Button>

                    <Grid Grid.Column="3">
                        
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition />

                        </Grid.ColumnDefinitions>


                        <TextBlock x:Name="OpenCool"
                               Grid.Column="0"
                               FontFamily="Segoe UI"
                               FontSize="10"
                               FontStyle="Normal"
                               Margin="0,2,0,0"
                               TextDecorations="Underline"
                               Cursor="Hand"
                               HorizontalAlignment="Right"
                               >
                            <TextBlock.Foreground>
                                <SolidColorBrush Color="Blue" />
                            </TextBlock.Foreground>

                            <TextBlock.Text>
                                Open Cool Window
                            </TextBlock.Text>
                        </TextBlock>

                        <TextBlock x:Name="OpenPower"
                               Grid.Column="1"
                               FontFamily="Segoe UI"
                               FontSize="10"
                               FontStyle="Normal"
                               Margin="0,2,0,0"
                               TextDecorations="Underline"
                               Cursor="Hand"
                               HorizontalAlignment="Right"
                               >
                            <TextBlock.Foreground>
                                <SolidColorBrush Color="Blue" />
                            </TextBlock.Foreground>

                            <TextBlock.Text>
                                Open System Power Options
                            </TextBlock.Text>
                        </TextBlock>

                    </Grid>
                    
                </Grid>

                <!-- Main Display Grid -->
                <Grid HorizontalAlignment="Stretch" 
                      Margin="38,0,38,0" 
                      VerticalAlignment="Stretch">

                    <Grid VerticalAlignment="Stretch">

                        <Grid.RowDefinitions>
                            <RowDefinition Height="14"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>

                        <TextBlock 
                            Grid.Row="0"
                            Grid.Column="0"
                            FontFamily="Segoe UI"
                            FontSize="10"
                            x:Name="PowerStatus"
                            ToolTip="{Binding PowerStateDescription}"
                            Text="{Binding PowerStateDetail}"
                            VerticalAlignment="Bottom"
                            HorizontalAlignment="Right"
                            >
                            <TextBlock.Foreground>
                                <SolidColorBrush Color="{Binding UtilityColor}" />
                            </TextBlock.Foreground>

                        </TextBlock>

                        <controls:StatusDisplay 
                            Grid.Row="1"
                            VerticalAlignment="Stretch"
                            HorizontalAlignment="Stretch"
                            ItemSpacing="0,0,0,0"
                            x:Name="Monitor"
                            >
                        </controls:StatusDisplay>

                    </Grid>

                </Grid>

            </Grid>

        </Grid>

        <Grid Grid.Row="0" Grid.Column="0" Grid.RowSpan="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="40"/>
                <RowDefinition Height="128"/>
                <RowDefinition Height="20"/>
                <RowDefinition Height="60"/>
            </Grid.RowDefinitions>
            <Grid Grid.Row="0" Grid.Column="0" Margin="12,12,12,12">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="0" 
                               x:Name="ProductId" 
                               Text="{Binding ProductString,Mode=OneWay}"
                               Foreground="{DynamicResource TrippLiteGray}" 
                               FontFamily="Segoe UI" FontSize="10" 
                               HorizontalAlignment="Center" 
                               VerticalAlignment="Center">

                    </TextBlock>

                </Grid>
            </Grid>
            <Grid Grid.Row="3" Grid.Column="0" Margin="12,0,12,0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="20"/>
                        <RowDefinition Height="20"/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" 
                               x:Name="LabelSerial"
                               Foreground="{DynamicResource TrippLiteDimGray}" 
                               FontFamily="Segoe UI" 
                               FontSize="8" 
                               HorizontalAlignment="Center" 
                               VerticalAlignment="Bottom">
                        Serial Number
                    </TextBlock>
                    <TextBlock Grid.Row="1" 
                               x:Name="SerialNo" 
                               Text="{Binding SerialNumber,Mode=OneWay}"
                               Foreground="{DynamicResource TrippLiteGray}" 
                               FontFamily="Segoe UI" 
                               FontSize="11" 
                               HorizontalAlignment="Center" 
                               VerticalAlignment="Bottom">

                    </TextBlock>
                </Grid>
            </Grid>
            <Grid Grid.Row="2" Margin="4,0,4,0">
                <TextBlock Grid.Row="1" 
                           x:Name="ModelId" 
                           Foreground="{DynamicResource TrippLiteGray}" 
                           Text="{Binding ModelId,Mode=OneWay}"
                           FontFamily="Segoe UI" 
                           FontSize="10" 
                           HorizontalAlignment="Center" 
                           VerticalAlignment="Center">

                </TextBlock>
            </Grid>
            <Grid Grid.Row="1" Grid.Column="0" Grid.RowSpan="1"  Margin="12,12,12,12">
                <Grid 
                    HorizontalAlignment="Stretch" 
                    VerticalAlignment="Center" 
                    Height="84">

                    <Image x:Name="ModelImage"
                           VerticalAlignment="Center" 
                           HorizontalAlignment="Center" 
                           Stretch="Uniform"
                           Source="{StaticResource Smart1500LCDT}">

                        <Image.BitmapEffect>
                            <DropShadowBitmapEffect Color="{DynamicResource ShadowColor}" Direction="199" Softness="0.4" ShadowDepth="3" />
                        </Image.BitmapEffect>

                        <Image.SnapsToDevicePixels>True</Image.SnapsToDevicePixels>

                        <Image.Style>
                            <Style>
                                <Setter Property="RenderOptions.BitmapScalingMode" Value="HighQuality" />
                            </Style>
                        </Image.Style>

                    </Image>

                </Grid>
            </Grid>
        </Grid>


    </Grid>
</Window>
